<?php

namespace common\core\controller;

use common\core\filter\HttpHeaderAuth;
use common\core\filter\QueryParamAuth;

class RestController extends PublicController
{
    public function behaviors()
    {
        $behaviors = parent::behaviors();

        $paramAuth = new QueryParamAuth();
        if (\Yii::$app->request->get($paramAuth->tokenParam)) {
            $behaviors['queryParamAuth'] = [
                'class' => get_class($paramAuth),
            ];
        }

        $headerAuth = new HttpHeaderAuth();
        if (\Yii::$app->request->getHeaders()->get($headerAuth->header)) {
            $behaviors['httpHeaderAuth'] = [
                'class' => get_class($headerAuth),
            ];
        }

        return $behaviors;
    }
}
